package com.nuoniu.sibanyun.controller.erp;


import com.nuoniu.sibanyun.common.BaseController;
import com.nuoniu.sibanyun.common.result.HttpResult;
import com.nuoniu.sibanyun.entity.dto.ErpAccountEditDto;
import com.nuoniu.sibanyun.entity.erp.ErpAccount;
import com.nuoniu.sibanyun.service.erp.IErpAccountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 账套信息 前端控制器
 * </p>
 *
 * @author baiqiang
 * @since 2020-09-22
 */
@RestController
@RequestMapping("/erp/account")
@Api(tags = "账套信息")
public class ErpAccountController extends BaseController {

    @Autowired
    private IErpAccountService erpAccountService;

    @GetMapping("/list")
    @ApiOperation(value = "查询租户账套集合")
    public HttpResult<List<ErpAccount>> list() {
        return HttpResult.ok(erpAccountService.listErpAccount());
    }

    @PostMapping("/add")
    @ApiOperation(value = "新增账套")
    public HttpResult add(@RequestBody ErpAccount erpAccount) {
        erpAccountService.addErpAccount(erpAccount);
        return HttpResult.ok();
    }

    @PostMapping("/edit")
    @ApiOperation(value = "编辑账套")
    public HttpResult edit(@RequestBody ErpAccountEditDto erpAccountEditDto) {
        erpAccountService.editErpAccount(erpAccountEditDto);
        return HttpResult.ok();
    }

    @GetMapping("/getLastErpAccount")
    @ApiOperation(value = "获取当前账套")
    public HttpResult<ErpAccount> getLastErpAccount() {
        return HttpResult.ok(erpAccountService.getLastErpAccount());
    }

}
